/*
 * @lc app=leetcode.cn id=1200 lang=javascript
 *
 * [1200] 最小绝对差
 */

// @lc code=start
/**
 * @param {number[]} arr
 * @return {number[][]}
 */
var minimumAbsDifference = function (arr) {
  arr.sort((a, b) => a - b);
  let res = [[arr[0], arr[1]]];
  let diff = arr[1] - arr[0];
  for (let i = 2; i < arr.length; i++) {
    const temp = arr[i] - arr[i - 1];
    if (temp === diff) {
      res.push([arr[i - 1], arr[i]]);
    } else if (temp < diff) {
      diff = temp;
      res = [[arr[i - 1], arr[i]]];
    }
  }
  return res;
};
// @lc code=end

